home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NOVA - For the NeXT Workstation
/
NOVA - For the NeXT Workstation.iso
/
SourceCode
/
Tutorial
/
Cookbook
/
29.Dice
/
rand.c
< prev
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
C/C++ Source or Header
|
1992-12-19
|
317 b
|
18 lines
#include <libc.h>
#include <sys/time.h>
#define MAXRND 2147483649
#include <sys/time.h>
extern long random();
extern void srandom();
int getrand(int MaxVal)
{
struct timeval tp;
struct timezone tzp;
gettimeofday(&tp, &tzp);
srandom((int) tp.tv_usec );
return(MaxVal * ((float) random()/(float) MAXRND) + 1 );
}